<?php
/**模块公用控制器
 * @Author: happy
 * @Email:  976123967@qq.com
 * @Date:   2015-07-14 22:04:39
 * @Last Modified by:   cl
 * @Last Modified time: 2015-08-09 19:32:13
 */

namespace Common\Controller;

use Think\Controller;
use Think\Upload;

class ExtendController extends Controller
{


    /**
     * [down 下载]
     * @return [type] [description]
     */
    public function down()
    {
        $id   = I('get.id');
        $data = D('Upload')->find($id);
        if (!$data)
            $this->error('文件不存在');
        $file     = $data['path'] . '/' . $data['name']; //文件路径
        $fileName = $data['remark'];            //获得文件名

        header('content-type:application/octet-stream');
        header('accept-ranges: bytes');
        header('content-length: ' . filesize($file));
        header('content-disposition:attachment;filename=' . $fileName);
        $fp = fopen($file, "r");
        while (!feof($fp)) {
            echo fgets($fp, 4096);
        }
        fclose($fp);
    }


    public function verify()
    {

        $fontSize = I('get.fontSize', 14);
        $config   = array(
            'codeSet'  => '0123456789',
            'length'   => 4,
            'fontSize' => $fontSize,
            'fontttf'  => '5.ttf'
        );
        $Verify   = new \Think\Verify($config);
        $Verify->entry();
    }


}